Repository navigation
Conversation
- date.trunc compiles to TRUNC(col, 'MM') with Oracle's format models; units below a minute are reported as unsupported - date.to_text compiles to TO_CHAR with Oracle format models; Oracle's FM is a toggle, so it's switched off after each element - date.diff reports that Oracle has no DATEDIFF, instead of emitting it - TIMESTAMP literals separate date and time with a space (ORA-01861 with T) - intervals are INTERVAL '3' DAY, with a leading precision above two digits; weeks become days, milli- and microseconds fractional seconds - time literals are reported as unsupported: Oracle has no TIME type Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
prql-bot
left a comment
There was a problem hiding this comment.
Two small things inline: a panic on a large weeks interval, and an override that never gets called. The rest of the Oracle mapping looks right to me.
Oracle's TIMESTAMP literal requires the seconds (ORA-01861 for @2030-06-01T10:30) and an offset written as ±HH:MM (ORA-01874 for -0800, ORA-01882 for Z). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
Pushed a follow-up: Oracle's |
prql-bot
left a comment
There was a problem hiding this comment.
oracle_timestamp still lets two lexer-accepted forms through: an hour-only time and a fraction written right after the minutes. With target:sql.oracle, @2025-01-01T08 compiles to TIMESTAMP '2025-01-01 08' and @2025-01-01T08:15.5 to TIMESTAMP '2025-01-01 08:15.5', both of which Oracle rejects since it requires HH24:MI:SS. In each case the regex doesn't match, so the input falls back to replacen. The two inline suggestions go together (apply them as one batch). They make minutes, seconds and the fraction separate optional groups, so these become '2025-01-01 08:00:00' and '2025-01-01 08:15:00.5'. I ran test_oracle_dates locally with both applied and it still passes. The lexer always emits the offset as ±HHMM, so the offset arm also gets simpler.
- Oracle TIMESTAMP literals: an hour-only time and a fraction right after the minutes are completed too (`08` -> `08:00:00`, `08:15.5` -> `08:15:00.5`). - A `weeks` interval too large for days is an error instead of an overflow. - Drop OracleDialect::interval_quoting_style, which was never called: every Oracle interval goes through translate_oracle_interval. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
prql-bot
left a comment
There was a problem hiding this comment.
codecov/patch came back red on this head (91.36% of the diff covered, target 94.39%). It hadn't reported yet when I approved, so I'm withdrawing the approval until it's resolved. The uncovered lines include behavior the PR description promises: the double-quote compile error in date.to_text, and the whole-second output of fraction (2000milliseconds → INTERVAL '2' SECOND). The zero-padded MM/DD and unpadded FMHH24FM arms are uncovered too. The two inline suggestions add tests for all of these. I ran them locally and both test functions pass with the snapshots shown. That still leaves the replacen fallback in oracle_timestamp and the Unsupported interval unit arm uncovered.
CI failed — codecov/patch below target; see the follow-up review.
`%m`, `%d` and `%-H`; the errors for a double quote in a format and for a specifier Oracle can't produce; a whole number of seconds from milliseconds; and the two fallbacks the lexer doesn't reach (unit tests). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Problem
The date functions emit what Oracle lacks:
date.truncemitsDATE_TRUNC;date.to_textis "not yet supported for this dialect";date.diffemitsDATEDIFF;TIMESTAMP '2025-06-01T10:30:00'is ORA-01861 (Oracle wants a space);INTERVAL 1 DAY(unquoted, a syntax error) andINTERVAL 2 WEEK(no such field).Solution
date.trunccompiles toTRUNC(col, 'MM'). Units map to Oracle format models: yearYYYY, quarterQ, monthMM, weekIW(ISO, likeDATE_TRUNC('week')), dayDD, hourHH24, minuteMI. Units below a minute are a compile error, with a hint.date.to_textcompiles toTO_CHARwith Oracle format models. They're close to Postgres's, but Oracle'sFMis a toggle for the rest of the format, so it is switched off after each element (%-d/%-m→FMDDFM/FMMMFM). A double quote can't be produced by an Oracle format model, so it's a compile error.date.diffreports that the operator isn't supported, as on Postgres.TIMESTAMPliterals use a space between date and time.INTERVAL '3' DAY, with a leading precision above two digits (INTERVAL '100' DAY (3), ORA-01873 without it). Weeks become days; milli- and microseconds become fractional seconds.TIMEtype.Oracle's own interval arithmetic still differs from Postgres in one place:
DATE '2024-01-31' + INTERVAL '1' MONTHis ORA-01839 rather than Feb 29. That's how Oracle defines it.Testing
New inline tests:
test_oracle_dates,test_oracle_intervals,test_oracle_date_to_text. On Oracle:date_to_textmatch its snapshot on all 20 rows (the 12th contains a").date.trunc, date and timestamp literals, intervals of every unit, anddate.to_textmatch DuckDB.Verified on Oracle Database 19c Enterprise Edition 19.3 (Docker), beyond the inline snapshots:
sql::Dialect::Oraclesnapshot intests/integration/sql.rswas executed on the database;tests/integration/queries) was compiled tosql.oracleand run against the Chinook data loaded into Oracle (quoted lower-case names), comparing rows with theresultssnapshots;sql.duckdb) and Oracle (sql.oracle), comparing rows.cargo test -p prqlc --all-targets,cargo clippy -p prqlc --all-targets -- -D warningsandcargo fmt --checkare green. The harness is outside this repo; happy to share it or contribute an Oracle runner totests/integration/dbsif that's wanted (the Oracle images need a registry login, which is why I haven't proposed it here).This is one of a series of independent PRs that make
sql.oracleoutput run on Oracle 19c (the oldest release in support). With all of them applied, 27 of the 31 integration queries return their snapshot results on Oracle (18 onmain; the other 4 areread_csv, two s-string queries with unquoted lower-case table names, and the double quote indate_to_text), and 39 of 40 DuckDB-differential queries match (9 onmain).🤖 Generated with Claude Code